<?php
namespace app\pc\controller;
use think\Db;
use think\Request;

use app\pc\model\News as NewsModel;
//新闻
class News extends Common
{
    
  public function getList(Request $request)
  {
      $page =$request->param('page',1,'intval');

      to_json_encode(200,'success',NewsModel::handleList(NewsModel::getList($page)));
  }

  public function getContent(Request $request)
  {
     $news_id = $request->param('news_id');
     if(!is_numeric($news_id))
     {
       to_json_encode(400,'参数错误',['status'=>false]);
     }
    
     $info = NewsModel::getNewsInfo($news_id);
      
     if(empty($info) || $info['news_is_publish'] == 0)
     {
       to_json_encode(400,'没有数据',['status'=>false]);
     }
     $info = NewsModel::handleInfo($info);
     $info['content']=htmlspecialchars_decode(NewsModel::getNewsContent($news_id));
     to_json_encode(200,'success',$info);
    
  }
}
